package com.lhc.springboot_mybatispuls.components;

//import org.apache.logging.log4j.message.Message;
import com.alibaba.fastjson.JSONObject;
import com.lhc.springboot_mybatispuls.entity.Test;
import com.lhc.springboot_mybatispuls.repository.TestDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

//@Component
public class MsgListener implements MessageListener {
    @Autowired
    TestDao testDao ;
    @Override
    public void onMessage(Message message, byte[] pattern) {
        JSONObject jsonobject = JSONObject.parseObject(message.toString());
        Test test = new Test();
        test.setTime_stamp_report(jsonobject.getString("Time_Stamp_Report"));
        test.setTitle(jsonobject.getString("Title"));
        testDao.insert(test);

        System.out.println( "Message: " + test.getTime_stamp_report() );
    }
}

